Skip to content

Fix Beacon API JSON envelope for blobs endpoint#54

Merged
niran merged 2 commits into
masterfrom
codex/peerdas-blob-wrapper
May 13, 2026
Merged

Fix Beacon API JSON envelope for blobs endpoint#54
niran merged 2 commits into
masterfrom
codex/peerdas-blob-wrapper

Conversation

@niran

@niran niran commented May 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Return a Beacon API JSON response object from GET /eth/v1/beacon/blobs/{id} instead of encoding the blobs array directly.
  • Include the spec-required execution_optimistic, finalized, and data fields for JSON responses.
  • Preserve the existing SSZ behavior: application/octet-stream still returns the raw serialized blob list.
  • Update regression tests so they assert the JSON envelope shape and filtered blob ordering.

Context

The PeerDAS/Fulu support added a /eth/v1/beacon/blobs/{block_id} route as the fallback-compatible blob endpoint. The handler converted archived blob sidecars into v1.Blobs, but encoded that slice directly for JSON responses.

That was not Beacon API-compatible. Beacon API JSON responses wrap returned payloads under a top-level data key, and the getBlobs response schema also includes execution_optimistic and finalized. SSZ is the format that returns raw serialized blob-list bytes.

This broke op-node fallback compatibility because op-node calls /eth/v1/beacon/blobs/{slot} and decodes the response into eth.APIBeaconBlobsResponse, which expects data to contain the blob array. A top-level JSON array cannot decode into that wrapper type.

The original tests missed this because they unmarshaled the response directly into v1.Blobs, which matched the incorrect implementation rather than the Beacon API response shape.

Testing

  • go test ./...

@cb-heimdall

cb-heimdall commented May 11, 2026

Copy link
Copy Markdown
Collaborator

✅ Heimdall Review Status

Requirement Status More Info
Reviews 1/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

Comment thread api/service/api_test.go Outdated
Comment on lines +397 to +402
var responseBody map[string]json.RawMessage
err = json.Unmarshal(response.Body.Bytes(), &responseBody)
require.NoError(t, err)
require.Contains(t, responseBody, "execution_optimistic")
require.Contains(t, responseBody, "finalized")
require.Contains(t, responseBody, "data")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would personally default to skipping this sort of test case, as it's mostly redundant with the beaconBlobsResponse unmarshaling below

Comment thread api/service/api_test.go Outdated
Comment on lines +486 to +491
var responseBody map[string]json.RawMessage
err = json.Unmarshal(response.Body.Bytes(), &responseBody)
require.NoError(t, err)
require.Contains(t, responseBody, "execution_optimistic")
require.Contains(t, responseBody, "finalized")
require.Contains(t, responseBody, "data")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Comment thread api/service/api.go Outdated
Comment on lines +223 to +227
type beaconBlobSidecarsResponse struct {
ExecutionOptimistic bool `json:"execution_optimistic"`
Finalized bool `json:"finalized"`
Data []*deneb.BlobSidecar `json:"data"`
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style: avoid interleaving struct definitions with the rest of the code.
In this case I'd just move this to the top of the file

Comment thread api/service/api.go Outdated
ExecutionOptimistic bool `json:"execution_optimistic"`
Finalized bool `json:"finalized"`
Data v1.Blobs `json:"data"`
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

@niran niran requested a review from BrianBland May 11, 2026 19:23
@niran niran merged commit df1f6e8 into master May 13, 2026
6 of 7 checks passed
@BrianBland BrianBland deleted the codex/peerdas-blob-wrapper branch May 13, 2026 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants